-
Notifications
You must be signed in to change notification settings - Fork 41
Make entity fields required by default #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this contribution, @olivier-thatch! The changes look generally good, and I appreciate that you not only highlighted this problem, but also suggested a solution. I do have some thoughts on a potential simplification in one of the methods, which I've detailed in a comment below.
0a992e3
to
14455d2
Compare
14455d2
to
e017856
Compare
07a3f3b
to
374be93
Compare
I've updated the PR to account for another case of conditional exposure: |
374be93
to
1bdd95f
Compare
Hi @numbata, any chance this could get merged and released sometimes soon? |
I'll merge this, open an issue for a release, can do if we don't see @numbata for a while. |
I'll do release tomorrow (if that's okay), but I think we should add a bit words into the CHANGELOG or README, as this PR changes existing behavior. |
@numbata Good call, def increment the version accordingly. |
LGTM! Release it |
Thank you both! 🎉 |
This PR changes how grape-swagger-entity determines if an entity field is required or not:
documentation: { required: true/false }
is set, use thatif
orunless
is not null or ifexpose_nil
isfalse
, assume the parameter is not requiredThis is consistent with how grape-entity renders fields: fields are always exposed unless
if
orunless
is provided (cf. https://github.com/ruby-grape/grape-entity?tab=readme-ov-file#conditional-exposure).Closes #80.
This is probably a breaking change, so I understand if you don't want to merge this as is, but it would be nice to be able to opt into this behavior.